<?php
/**
 * 登录服务
 */

namespace polymerize\auth\service;

use app\common\InstanceTrait;
use polymerize\auth\module\login\AliGetMobile;
use polymerize\auth\module\login\AppleLogin;
use polymerize\auth\module\login\LoginByMobile;
use polymerize\auth\module\login\PasswordLogin;
use polymerize\auth\module\login\QQLogin;
use polymerize\auth\module\login\TouristLogin;
use polymerize\auth\module\login\WechatAppLogin;
use polymerize\auth\module\login\WechatLogin;
use polymerize\auth\module\login\WeiboLogin;

class LoginService
{
    use InstanceTrait;

    /**
     * 阿里云一键登录
     * 三网通手机号码一键登录
     *
     * @param string $accessToken
     * @param string $ref
     * @return array
     */
    public function aliGetMobile(string $accessToken, string $ref): array
    {
        return AliGetMobile::getInstance()->aliGetMobile($accessToken, $ref);
    }

    /**
     * 手机验证码登录[发送短信验证]
     *
     * @param int    $mobile
     * @param int    $smsCode
     * @param string $ref
     * @return array
     */
    public function loginByMobile(int $mobile, int $smsCode, string $ref): array
    {
        return LoginByMobile::getInstance()->loginByMobile($mobile, $smsCode, $ref);
    }

    /**
     * 账号密码登录
     *
     * @param int    $mobile
     * @param string $password
     * @return array
     */
    public function passwordLogin(int $mobile, string $password): array
    {
        return PasswordLogin::getInstance()->passwordLogin($mobile, $password);
    }

    /**
     * 微信登录
     *
     * @param string $code
     * @param string $state
     * @param string $ref
     * @param int    $bindUid
     * @return array
     */
    public function wechatLogin(string $code, string $state, string $ref, int $bindUid): array
    {
        return WechatLogin::getInstance()->wechatLogin($code, $state, $ref, $bindUid);
    }

    /**
     * 微信小程序微信登录
     *
     * @param string $code
     * @param string $encrypteData
     * @param string $iv
     * @param string $ref
     * @return array
     */
    public function wechatAppLogin(string $code, string $encrypteData, string $iv, string $ref): array
    {
        return WechatAppLogin::getInstance()->wechatAppLogin($code, $encrypteData, $iv, $ref);
    }

    /**
     * QQ登录
     *
     * @param string $token
     * @param string $ref
     * @param int    $bindUid
     * @return array
     */
    public function qqLogin(string $token, string $ref, int $bindUid): array
    {
        return QQLogin::getInstance()->qqLogin($token, $ref, $bindUid);
    }

    /**
     * 微博登录
     *
     * @param string $token
     * @param int    $weiboUid
     * @param string $ref
     * @param int    $bindUid
     * @return array
     */
    public function weiboLogin(string $token, int $weiboUid, string $ref, int $bindUid): array
    {
        return WeiboLogin::getInstance()->weiboLogin($token, $weiboUid, $ref, $bindUid);
    }

    /**
     * apple登录
     *
     * @param string $identityToken
     * @param string $ref
     * @param int    $bindUid
     * @return array
     */
    public function appleLogin(string $identityToken, string $ref, int $bindUid): array
    {
        return AppleLogin::getInstance()->appleLogin($identityToken, $ref, $bindUid);
    }

    /**
     * 游客登录
     *
     * @param string $uuid
     * @return array
     */
    public function touristLogin(string $uuid): array
    {
        return TouristLogin::getInstance()->touristLogin($uuid);
    }
}